package day05.shuzu;

public class Lian05 {
    public static void main(String[] args) {
        int[] arr = {6, 1, 2, 7, 9, 3, 4, 5, 10, 8};
        add(arr, 0, arr.length - 1);
        for (int i = 0; i < arr.length; i++) {
            System.out.print(arr[i] + " ");
        }
    }

        private static void add ( int[] arr, int left, int right){
            int left0 = left;
            int right0 = right;
            int num = arr[left0];
            while (left != right) {
                while (arr[right] >= num && right > left) {
                    right--;
                }
                while (arr[left] <= num && right > left) {
                    left++;
                }
                int temp = arr[left];
                arr[left] = arr[right];
                arr[right] = temp;
            }
            int temp = arr[left];
            arr[left] = arr[left0];
            arr[left0] = temp;
        }
    }
